<?php
session_start();

if (isset($_POST['forum_topic'])) {
    $topic = $_POST['forum_topic'];
}
if (isset($_POST['message'])) {
    $message = $_POST['message'];
}

if ($topic != "" && $message != "") {
    $now = time();
    
    //get user id from session which is currently logged in user's user id.
    $user_id= $_SESSION['user_id'];
    $parent_id=0;
    
    mysql_connect("localhost","root","");
    mysql_select_db("susudo");

    $forum_query="INSERT INTO `forum` (`id`, `user_id`,`forum_topic`,`forum_content`,`parent_id`,`created_at`)
        VALUES (NULL,$user_id,'$topic','$message',$parent_id,'$now');";
    mysql_query($forum_query);

    mysql_close();

    header("location: ../frontend.php?page=forum");
    //echo "<p style='color:#00f'>Hi, $fullname, thanks for the information. </p> ";


}
else {
    header("location: ../frontend.php?page=forum");
}

;
?>
